package com.casic.ops.entity.dto.pipeline;

import com.alibaba.fastjson.annotation.JSONField;
import com.casic.ops.consts.user.UserHolder;
import com.casic.ops.utils.OpsSnowFlake;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 流水线执行记录DTO
 * @author cww
 * @date 2022/6/17
 */
@Data
@Accessors(chain = true)
public class PipelineLoggerDTO extends CommonDTO{
    /**
     * 流水线uuid
     */
    private long pipelineUuid;
    /**
     * 存储数据正文
     */
    private String content;
    /**
     * 流水线快照
     */
    private String graphContent;
    /**
     * 执行时间
     */
    @JSONField(format="yyyy/MM/dd HH:mm:ss")
    private Date executeStartTime;
    /**
     * 结束时间
     */
    @JSONField(format="yyyy/MM/dd HH:mm:ss")
    private Date executeEndTime;
    /**
     * 最终执行状态
     */
    private String finalStatus;

    /**
     * 触发方式
     */
    private String triggerWay;

    public void init(){
        this.setCreator(UserHolder.get().getUsername());
        this.setModifier(UserHolder.get().getUsername());
        Date date = new Date();
        this.setGmtCreate(date);
        this.setGmtModified(date);
        this.setUuid(OpsSnowFlake.getInstance().nextId());
    }
}
